#include <stdio.h>
#include <stdlib.h>

#define SIZE 100

int cmp(const void *a, const void *b)
{
	if (*(int *)a < *(int *)b)
		return -1;
	else
		return 1;
}

int main()
{
	int n;
	scanf("%d", &n);
	int square = n*n;
	int tmp = 0;
	int a[SIZE] = { 0 };
	int i = 0;
	for (i = 0; square != 0; i++)
	{
		a[i] = square % 10;
		square /= 10;
	}
	int len = i;
	qsort(a, len, sizeof(int), cmp);
	for (i = 0; i < len; i++)
	{
		printf("%d\n", a[i]);
	}
	return 0;
}